I'm translating this sentence
たまにはひとり気まま に ブラつくのもいいか?
and I understood something like Is it okay to wander alone and carefree sometimes?, but I'm not sure because I don't understood the function of that に in this case, Someone can explain me how it works here?