fix keyerror bug in open_tags