Moved logic from controller to Command