refactored to use other mathgl
added the refactor script