merged Fares's code