cleaned the code moore readable, more sensible