added mathjs and cleaned up some code