Closed #4 Cleaned up JS code