Refactored build_curves