pet peeve: i should always be an index variable. Change "i" to "type".