fixed init method, added protection against non-existent target directory