clean up and added switch statement