Refactored class code to javascript files