Modified the function