Final commit - updated and refactored code