Update code according to comments of the PR