unneeded allocation
type annotations + restructuring