updated count function in posts class