rework code to use work with non-oop style