implemented the offset function to work properly, needs to be tested