remove excess text from javascript