start to refactory backend codes