Adding some more error detection