Made some small changes to get script to work