Why does this return null instead of being a void method?