adding err checks