working logic, still experimenting