refactored in preparation for graft command
making tag resolve more lazy to make it faster