cleaned up js template and functions