Studies on bare and Mg-doped LiCoO2 as a cathode material for lithium ion batteries