merge code from carl