merged code #2