Improved javascript