Added abstract counting logic