more refucktoring of code