Modified to accept IP value from user. Minor comment change and code beautification