fixed out range bug