Minor code rearange