Improved data rate function and #define