added auto to some loops