added auto memory freeing at runtime end