put condition evaluation on it's own function