Moved offset declaration from constructor to function