replaced and.or with &&/|| (less readable but...)