Made some changes, thanks to JFo.nz