I have posted the question in stack overflow
The answer by the Stack Overflow user "kcorlidy" looks correct to me.