modified for FreeBSD10.0