function bug fixed