Made this quicker (sometimes it failed because it was taking too long).