Moved safe_counter from main to utility