complete rewrite
added keys conversions
skeleton