added logic for the initialization vector