why do you define this function twice?

I'm worried there's something wrong with your editor with so many sections of repeated code. You should check up on your dev environment.