Updated code according reviews