tweaked to remove compile warnings