Template from w0ng's hybrid scheme