Cleaned totalBytes function