added more checking