small bug fix & checking for null value in prefixArray