updated code from prototype to final
clear