properly run the code in main queue.