works but still uses sort method to check, so more work needed