Refactoring: moved protocol helper function to a separate file