Copied across the code and made it work again