Added more checks and made them more accurate