Refactoring
(cherry picked from commit b50ba06)
(cherry picked from commit 9c608b9)