implemented membrane, ugly spagetti code, mostly hardcoded, BUT running