Fixed bad index when using poscars