algorith error fixed