A method for fencing animals without the use of a physical fence by means of a system including a portable device for attachment to an animal using fastening means, which portable device is provided with power supply means, a GNSS unit, microcontroller provided with external or internal storage means for generating electric shock, and communication means (20a-b), characterized in that the method involves the following steps: a) system reboot or wake-up from power saving mode, b) acquiring current position, speed and validity for the position measurement for an animal, and if the animal's speed is above a configured threshold, no further correction is performed, and where degree of freedom is updated and reset after a valid position measurement is done, and measurements show that the animal is located within a defined area, c) checking the current position of the animal in relation to defined area(s) by means of at least one polygon, d) calculate distance to nearest border line of the configured area(s), e) checking whether the current position from step c) is within configured area(s), where if the checked position in step c) is inside configured area(s) set the system in power saving mode and if the position from step c) is outside configured area(s), the method continue to step f), f) checking if calculated distance in step d) is such that correction is to be performed, g) start correction in the form of affecting the animal in the form of audio, where the audio frequency increases or decreases gradually according to calculated distance to configured area(s), h) checking if the distance to configured area(s) increases and if it is increasing checking if the audio frequency has reached a predetermined frequency level for electric shock and if the predetermined level is reached, apply an electric shock to the animal, or else return to step g), i) calculating actual position and registering actual position as a new starting point for further correction, j) end correction and return to step b). a) system reboot or wake-up from power saving mode, b) acquiring current position, speed and validity for the position measurement for an animal, and if the animal's speed is above a configured threshold, no further correction is performed, and where degree of freedom is updated and reset after a valid position measurement is done, and measurements show that the animal is located within a defined area, c) checking the current position of the animal in relation to defined area(s) by means of at least one polygon, d) calculate distance to nearest border line of the configured area(s), e) checking whether the current position from step c) is within configured area(s), where if the checked position in step c) is inside configured area(s) set the system in power saving mode and if the position from step c) is outside configured area(s), the method continue to step f), f) checking if calculated distance in step d) is such that correction is to be performed, g) start correction in the form of affecting the animal in the form of audio, where the audio frequency increases or decreases gradually according to calculated distance to configured area(s), h) checking if the distance to configured area(s) increases and if it is increasing checking if the audio frequency has reached a predetermined frequency level for electric shock and if the predetermined level is reached, apply an electric shock to the animal, or else return to step g), i) calculating actual position and registering actual position as a new starting point for further correction, j) end correction and return to step b).