fixed out of bound issue