Refactored model and added set_flashdata to cp