Refactored to pass arrays in compare method rather than the constructor