Move database logic to another file