Code refactoring and fixed a bug where the type of the location was not properly stated when removed