clean up code, added new detection