merged code with upstream