added toObject method