Completely refactored to replace array with hashes & method introduced to allow automatic date detection