added tweaks suggested after code review