cleaned up ftok thing a bit