removed panic - return an error for problems.