refactoring, make it work better