incorporate with Jie's updated codes