[amelia] correcting "index out of range" problem