Modified the routine functions some more