Cleaned up js code