changed secondPass to properly read flats argument