Cleaned up JavaScript so it's easier to configure