merged changes from Carles