main half refactured