moved some things around and removed warnings