free memory functions added