generalized to allow just directory input