moved log() to the main thread