Bug-fix: wait for all data arrive before return to logic