better codepath factoring