finished logic for gateMDRoutput