Make error checking more specific