made some fixes as per comments