removed unused var r and updated comments.