Refactor handle into func and db fetching into its own func. prepare for pakcgae later