added a lot of encryption related code