refactored the code by putting prettydate function in separate js file.