fixing offset bug