further code refactoring