Initial verion based on code found in internet, but added logging to file