draft implementation which works correctly
added result function