fixing bad javascript output