refactor - extract layer related code to method.