some rearangment , added bes file generation