definitely a problem with my traverse function