fixed gap problem
final version without bugs