Nearly finished light-building algo