refactored parsing methods and added directory mode