fix js function