implemented the listHeads method