fix else if case so that it properly handles collection with one element