(regesm) : restructure the code