Small refactor for common function