finally working with external switch