Reverted back to a better working function.