Updated with some cleaner loops