Modified the code  and removed errors