updated ex1 function