Safety locking mechanism