Fixed issue with $document bening an array ref not an object