Cleaned up JS Code