Refactoring...to be continued...