I prefer if these functions can go to a separate .js file. Anyway this can be done after you get the functionality completed.