Fixed delete function to use active record