fixing some JS problems