write the rl engine part