Fixed errors in replaced code