added gap check