Fixed the freezing. Added filename variable