changed function into a pure function