fixed variable declarations (into arguments) and combined some operations in the cipher function