fix for function bug