used threads in GUI, added average calculation