fixed handling of factors