Some code simplification by using traverse