Added check for a potential nil map