merged code with Ali
update