Code cleaned, added some comments, implemented warning message