Code modifications according to discussion