fixed matlab bugs