Function to call either single post or category

If this is the same if/else, you can just combine into if ( is_category() || is_single() ). You don’t need to pass anything to is_category() or is_single() most of the time, unless you are looking for a category or post in particular.