code cleanup, functionality separation