extracted some common functions. now ready for reusing said functions in the IROS model: