refactored: apply some principles like DRY or separation of concerns