decomposing into separate functions + type annotations