rewrite version (shall be cleaner)