Fix logic error in legacy code.