write more functional-programming-ly