Fixed problems with javascript