Adding in a dispatch call to prevent deadlock on the main thread