buggy version of incremental algo working