replacing print with logging
using os.path.join where appropriate