refactored Layer.py