moved ips_layout check to earlier in the method, and added unit test