Refactor based on review comments