refactored and added centos support