added some fixes on code