optimize code organization and start to develop flip button