Fixed bug in processing logic