huge code simplification