JS function fix