fix a terrible error that caused segfaults