cleaned up code to follow rules of javascript