Add some documentation and helper function