changed to using ipairs