Algorithm needs to be fixed