Made cmd and mags file read in dynamic