In this if statement we can't do contact.getLastName().equals().... because in several cases we last names are null (such as a contact Dad or Mom).  So calling null.equals() will throw a NullPointerException.  At least do a null check on contact.getLastName() before you do the .equals() on it.