Cleaned up js functions