refactor log into a component