Refactoring to make logic processor more readable