refractor the code for another purpose