minor FP-style function refactor