refactor GMSL code