initial code from january 2012