move branch detection inside condition, remove extra hash detection