refactor code: DRY