corrected funtioning