fixed javascript bugs