some logical fixes