Bug fix with beat detection