forecast algo, cleaned up queries