replace err with enum