modified for clarity/simplicity