Fix some issues in process function