Improve findActiveDocument