If it doesn't work outside the function putting it inside the function is fine.