added main pixel processing logic. first working version