fixed terminate method being placed in a wrong place