js validation fix and some clean up