modified for linux compatibility