added support for automatic placement detection