squashed 5 code improvement commits into 1