Changed the equals method in this function and added testing for it.