added some session code, its still not the nicest code but it works