fix bugs and javascript understanding