removed a small bug in user defined functions