Moved creating layer into delegate method