logic improvements and moved scanDir code into a class