made the container detection more robust