fixed code as per Chad's code review