working but not final
refactored working v1