updated the code to stream in https://gist.github.com/compermisos/2869706 and reformated to PSR-1 and PSR2