Moved master password reading into an utility function