merging code with Raul's