finished sparse encoder