Fix bug in flip count