implementing two more detection mechanism and some other minor changes