added pin change function