in reply to why does location of function matter?
Can't reproduce. Could you provide a small piece of working example code that demonstrates the problem?