failing ruby script, javascript cleaned up slightly