When I use a function which does everything I was supposed to code