adding head and tail pointer tracking before final checks