working javascript 5-way