fixed up a bit so that it works with centos 6