implemented code review comments: moved code above setter and corrected indentation