Fix bug in spec change function