Updated code so that it can run in one go, still needs results to be printed