some potential refactoring