fix labelling bug, and fix convert tofactor