simplify greatly
update for centos 5