added comments and documentation and removed the flow method in favor of just index