got rid of new/delete to prevent leaks and to use RAII style
got rid of new/delete to prevent leaks and to use RAII style