refactored hidden layer