Host Code Refactored+Tested