speed up by reducing num calls to num2str