fixed out of range problem