changing code as per review comments