moving code and simpliying