fixed errors in the previous commit
rust factored out