Move finish() to the right place in onDone() method