Fully fix #158 as other function seems deprecated in Moodle