UPD: made 'input' and 'output' dynamically