A bit more of refactoring, profiling is need