filter and flatMap added. Things are more readable now.