Added class existence check