modified magma functions not compatible with magma 1.6 (should still works with older versions)