cleaning js file and adding a couple utility methods