working towards parity with Yongsun's code