Modified for OS X compatibility