cleaning up js code