learning using Bo Qian's code snippets