functional version without text files