Fixed typo and added check