Fixed bug with saving records