better predict function for test data