added writting to index