Added find_by_code method and check expiry time.