formatting, fixed wrong indexing for updating offset