fixed a bug in function.js