select mostly written, seg fault needs debugging