Corrected getLastFolder method