re-factored a little bit