Re-Added a large portion of existing code