javascript syntax does not work well