final version with user interaction