finalizing functionality and added some comments