refactor, move logic to background, fix styles