slower but way more readable functional approach