solved edge cases with empty lists