Can you say what was the problem because it can be useful for many :)

Also you had an unused variable temp