refactored layers and separated helpers