algorithm fix

fix the jam problem