modified slightly for OpenBSD usage