moved setup code to a separate function

this might not work