seperated extractor & added error checking