handing error conditions better