Updated to be a bash script from Ruby