Added safety check mechanism (needs some work)