Flex Code refactoring