move logic to lib/ from app/