Moves some controller logic to document model