Added full (ugly) code from previous implementation.