refactoring
better memory management