Added proper functionality for the locations array