logic bug fixed