fixed out of bounds problems