changed structure of code and removed lint warning (mostly)