account validation logic extracted