javascript bugs fixed