Cleaned up code, added basic delay in loop