fixed index out of bounds for tags reaching too far,
made it compatible with latest nix version