Added a 'find_next_header' function