added token storage and restructured some brackets