refactor to command structure