In operant conditioning, the type and frequency of behavior are determined mainly by its consequences. If a certain behavior, in the presence of a certain stimulus, is followed by a desirable consequence (a reinforcer), the emitted behavior will increase in frequency in the future, in the presence of the stimulus that preceded the behavior (or a similar one). Conversely, if the behavior is followed by something undesirable (a punisher), the behavior is less likely to occur in the presence of the stimulus. In a similar manner, the removal of a stimulus directly following the behavior might either increase or decrease the frequency of that behavior in the future (negative reinforcement or punishment). For instance, a student that gained praise and a good grade after turning in a paper, might seem more motivated in writing papers in the future (positive reinforcement); if the same student put in a lot of work on a task without getting any praise for it, he or she might seem less motivated to do school work in the future (negative punishment). If a student starts to cause trouble in the class gets punished with something he or she dislikes, such as detention (positive punishment), that behavior would decrease in the future. The student might seem more motivated to behave in class, presumably in order to avoid further detention (negative reinforcement).