Cleaning up the Javascript for the database