clean code of MainLayer