I believe is better to move this code to an independent JS file