tidy up extra files
proper check for definned variable