modified from JB/hooligan