Made some changes to josh's code