Remove redundancy and make control flow a bit simpler