Refactor a bit for complexity