Moved commits logic to separate controller and fixed other concerns