restructure the codebase into couple of small functions.
i.e. No functions depend on each others