fix some functions in js