Moved and fixed compare()