Fixing memorybug