Added some checks and delay parameter for -w option