Refactor a bit more code