Removed redundancy and added abstraction