modified for bsd