Fixing count == 0 logic error