Refactored data.js more to condense code