translated two classes from chuck to javascipt