fixing code per Andres notes