Leverage recursive pattern matching to get rid of extra values