added documentation to search() method, moved some methods around