second, more complicated, less by random functioning example