Fixed problem that last records in database weren't resolved correctly