Added a few pre conditions based on array size