cleaned up javascript code and comments