fixed js function definitions