finish function
fixed bugs of javascript