fixed bug in equals function