fixing JavaScript example