restructured to smaller fns