Check if object is in array before adding it
Refactoring controller