diagonal algorithem fixed
diagonal algorithem fixed