modified for freebsd