cleanup, move logic where it belongs