cleaned up JS code and followed better standards