initial base code from tiantian