refactor crypt method