Copy over of Sasas code to apex