Rudimentary check working, but the code is getting messy