Added check for directory exist