Change query to async and create new funcs to handle