hacked version for use on FreeBSD