fix negative offset bug