Updating to work on our system. Still needs to be changed to work with postgresql though