Bug fix for serial code