commit message changed and made the code DRY level 1