changed function codes