I borrowed this code from another provider. I will make necessary changes here.