refactor code: a huge change in code structure