Implemented multithreading to make UI transition smoother