improving the scan toolbox ; extended num2leg function