started refactoring to extract macro
finished refactoring