Modify the condition for checking if it is a directory