Can you share the code of the complete file as everything seems ok with the above function.