Refactored indentation method to use proper recursion