outside-approach combined with almost REPL approach, finally a working code