use if condition instead of error catching