code cleanup

- no need for pointer
- move if statement into switch