fixed array out of bound exception
added save to file acion