traverse and create effective json