move logic to controller