Changed round with floor function to avoid IndexOutOfBounds

If length of a list is very small then round(length*0.95) equals length
and this leads to an IndexOutOfBounds.
Inserted additionally a check of list is empty.