Create handleStatus function