Did some error checking