Added checking for nil class