removing some rescue nil lines and improving error handling