minor refactoring and added date lookup
made import script more robust