Refactoring accounts list function