Code cleanup: move helper function inside caller
Improve code readability