Merge code for bet process