moved database calls till after environment check, for obvious reasons