performance optimization based on profiling
solved black_knot 400