Implemented tail recursion in array comparison