cleaned up the code & added few methods that can be helpful