changed position of System.gc()