refractor code.