rephrased functions to look slightly more haskell-y