adding error handling for conversion