refactored so that errors return are of exported variable types