Code refactor based on the comments.