code changes as suggested by Nagaraja