First working version, but needs manual interaction by user