Bug fix by Jack