working version before cleaning