implemented some needed subfunctions