with more ralphie
moved logic into proper functions