Have you defined temp as word ?- you do not show in your code.