add a regexp and remove directory useless check