improved javascript