fixed bugs in m conversion