refactored to use swing timer