made normalization a separate function