fixed major bug with database not being copied before it is needed