working version of modified code'