fixed bug with wrong javascript function