Moved common code into Util class