Refactored code and made prototype objects for ease of use