add helper function to avoid code douplication