written compare functions