corrected javascript for uninitialized variable