Cleaned up JavaScript