refactoring js object model part 1