Modified the codes to fix the errors due to type incompatibility