refactor variable assignment