refactored the rake query to email the correct output