handled case when solution is in a corner