Adding promote function and correcting some bugs