making to toObject method for passing headers around