Code cleanup and imported required package