Adding code for exhaustive search