Added streams and refactored