Fixed an endless loop.  Still buggy and code is becoming messy...need refactoring