re-factoring and cleaning up js code
started on jasmine to test js code