fixed shameful out of bound exceptions, fix #1522