move solving logic out of grid