Modified with more checks