refactored sound and animation code