traditional way to write this function, changing in next step to anonymous function