Fixed a logic error preventing exporting the databse