Understanding the origin of ferromagnetism in Er-doped ZnO system