Refactor a little bit