Right, maybe check type would be a good way to modularise this. This works for now though.