modified for Javascript