changed code with respect to comments