Refactored code with constructor function and prototype object
merge conflicts