refactors sub and ob logic into seperate file