fix to function bug