moved javascript funciton