fixed bug N=>M