moved the creation of layerselector to seperate function.