working version with video input
some changes here and there