Refactoring code for other cipher method