added check for null library