Replace before block logic with let statements