better solution to stock problems