move hosting code for reusability in other console apps