refactored cipher and conditionals