extracted logic from controller into domain model