modified javascript function blog