Adding database query to handler method