Use a more robust method for finding ctype_state