added basic precondition checks