Working on algorithm (function parameters only by value :()