more sophisticated version including the business logic