changed key format
changed writing method