added error handling for no structure going into subopt