Somewhat working but crashes for files