Fixed stupid bug and implement deletion function