js version implemented
some notes to self