Working version without refinement