merge stephomi‘s code