Refactored implementing code adding comments and removing final magic number