Code cleanup:
 * refactored search algo
 * new code to enter password