checked javascript code with JSlint and changed the code