fixed 0/-1 problem