minor code stylings
removed and refactored duplicate code