refactored code, interfaces added, magic numbers removed and code commented