added handling for different states