Fixed NaN and mysql query for beats