most cases catered for, huge refactor needed