More logic and replacement of vague code with clearere code