Changed script to be more platform independent