refactor, functionality improved