Final Completed Code