fixed phase counting error