final code changes as per Brandon's code review