mostly newly updated code