fixed call to as.environment()