refactor logic (separate concerns) to make things easier when multithreading