Corrected search method
Apply the functions when the document is ready.
Whitespace cleanup.