Reordering some code. Case function in progress.