Code updated according to feedback