fixing context and order of checks