updated processing code with proper comments