Fixed counting errors