Cleaned up JS a bit