javascript, bugs fixed