refactor for better structure