refactored
refactored 2, moved all the logic to the prototype