cleanup and create variable for base dir