used some helper methods, classes in pre order