javascript condition fix