add support for multiple documents; closes #3