Move some helper funtions to db_helper.py