fixed memory problem in a hacky way