added encryption and fixed a bug