Added comments and optimized the stream activity