null pointer bug fixing tested a new method for retrieving documents rather than sorting