somewhat rewritten due to feedback - stable build