refactor the code based on some fundemental changes outlined in Google doc SVIR some revisions