Cleaned up the code and added video playback