added check on index value to prevent index of -1 exception when measurements folder is empty