implement scaling frequency with debuging, stuck at segfault