remove whitespace and unneeded elements