updated version of code