Unfactor function modified to accept non factor objects