refactors the checking on creation/closure to handle all edge cases