separating controller logic into separate class