Refactor code (DRY)