Function to check array size rather than a load of if statements