improve code, added internal storage