Fix offset in event layer function