fixed bugs
fix from Andy