Modified logic for correct work in FreeBSD and Linux (V:1.0.2)