Integrated Tyson's and Michael's code