changed handling to array of structures