Cleaned up input
Cleaned up switch state code