restructuring code(not complited)