remove panic and return error
remove panic and return error