Javascript function call fixed