Fixing cypher function