refined logic and stable build