update implementation to implement Comparable<T>