moded pifm code for intergration into anyfesto framework