Function runs, but code function unclear