corrected error with function