fix out of bounds clearing bug